package com.yilin.medical.lsh;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class BaseRequest extends BaseBean {

	private static final long serialVersionUID = 4658875870108381995L;
	private String AccessKey = "0c5a3e8915871b710c2cc98073748424";
	private String SessionID = "52ef5e630++mOgLIsJ779r0k518fFPYAZyGAC9Or0YIg43BYUxkzxNKVfTI7AwucivvwQPg6SuWyUP2Rg0insw";

	public String getAccessKey() {
		return AccessKey;
	}

	public void setAccessKey(String accessKey) {
		AccessKey = accessKey;
	}

	public String getSessionID() {
		return SessionID;
	}

	public void setSessionID(String sessionID) {
		SessionID = sessionID;
	}

	public Map<String, Object> toMap(BaseRequest post) {
		Map<String, Object> map = new HashMap<String, Object>();
		Class<?> clazz = post.getClass();
		do {
			System.out.println(clazz.getName());
			for (Field field : clazz.getDeclaredFields()) {
				try {
					field.setAccessible(true);
					// System.out.println(field.getName() + field.get(post));
					map.put(field.getName(), field.get(post));
				} catch (IllegalArgumentException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			clazz = clazz.getSuperclass();

		} while (clazz.getName().contains("BaseRequest"));

		// System.out.println(map.toString());
		return map;
	}

}
